from my_utils.shell import ParameterUtil


class Hive(ParameterUtil):
    def e(self, sql):
        sql = sql.format(ymd=self.ymd).replace("'", '"')
        __db = "--database '{}'".format(self.get('hive_db')) if self.get('hive_db') else ''
        return self.evaluate(f"hive {__db} -e '{sql}'")


if __name__ == '__main__':
    print(Hive(hive_db='ec').e('SELECT f1,f2 FROM t WHERE ymd="{ymd}"'))
